<?php

/**
 * photo actions.
 *
 * @package    sfwixet
 * @subpackage photo
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class notificationsComponents extends sfComponents
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
  	$this->friendRequests = Doctrine::getTable("FriendRequest")->findByDql("user_receiver_id = ? AND status IS NULL",$this->getUser()->getId());
  	//New photo comments 
  	$photoComments = Doctrine::getTable("PhotoCommentNotification")->findByUserId($this->getUser()->getId());

  	if($photoComments)
  		$this->photoComments = $photoComments->count();
  	else
  		$this->photoComments = 0;
  		
  	//New tags	
  	$photoTags = Doctrine::getTable("PhotoTagNotification")->findByUserId($this->getUser()->getId());

  	if($photoTags)
  		$this->photoTags = $photoTags->count();
  	else
  		$this->photoTags = 0;
  		
   //New profile comments
  	$profileComments = Doctrine::getTable("ProfileCommentNotification")->findByUserId($this->getUser()->getId());

  	if($profileComments)
  		$this->profileComments = $profileComments->count();
  	else
  		$this->profileComments = 0;
  	
  	//New private message
  	$privateMessages = Doctrine::getTable("PrivateMessageNotification")->findByUserId($this->getUser()->getId());

  	if($privateMessages)
  		$this->privateMessages = $privateMessages->count();
  	else
  		$this->privateMessages = 0;

  	//
  	$this->visits = $this->getUser()->getGuardUser()->getProfile()->getVisits();
	
  	$user = $this->getUser()->getGuardUser();
  	$this->name = $user->getFirstname()." ".$user->getLastname()." ".$user->getSecondlastname();
  	$this->photoId = $user->getFace()->getId();
  }
  
  public function executeTitle(sfWebRequest $request)
  {
	
  }
}
